<template>
	<view>
		<view v-for="(item, index) in datalist" style="margin: 10rpx;">
			<cardViewText :imgindex="index" :images="item.images" :title="item.title" :isTop="item.isTop"
				:author="item.author" :comments="item.comments" :time="item.time" :mode="item.mode"
				:bgColor="item.mode === 3 ? '#fef6e6' : '#fff'" @click="onCustomViewClick(index)">
				<template v-slot:tips>
					<view class="slotcontent" v-if="item.showSearch">
						<text>搜索：</text>
						<view class="borderbox"><text>今日金价</text></view>
						<view class="borderbox"><text>精选好物</text></view>
					</view>
				</template>
			</cardViewText>
		</view>
	</view>
</template>

<script>
	import cardViewText from "../../components/cardViewText.vue";
	import news from "../../data/news.json";
	export default {
		components: {
			cardViewText
		},
		data() {
			return {
				datalist: news
			};
		},
		methods: {
			onCustomViewClick(index) {
				console.log("点击了第", index, "项");
			}
		}
	};
</script>

<style>
	.slotcontent {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		padding: 24rpx 0;
		font-size: 28rpx;
		color: #666;
		gap: 20rpx;
		border-top: 1rpx solid #f0f0f0;
		margin-top: 10rpx;
	}

	.borderbox {
		border: 1px solid #d0e3ff;
		border-radius: 12rpx;
		padding: 10rpx 20rpx;
		background: linear-gradient(135deg, #f0f7ff, #e1eeff);
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
	}

	.borderbox text {
		font-size: 24rpx;
		color: #1890ff;
		font-weight: 500;
	}
</style>
